<template>
	<view class="content">
		<view class="cont">
			<view class="cont_item" v-for="(item, index) in list" :key="index">
				<view class="cont_l">
					<image :src="ajax + item.avatar" mode=""></image>
					<!-- <image src="../../../static/yaoqing.png" mode=""></image> -->
					<view class="sex" v-if="item.gender == 0"><text class="sex1 iconfont icon-ziyuan2"></text></view>
					<view class="sex2" v-else><text class="sex1 iconfont icon-nan"></text></view>
				</view>
				<view class="cont_c">{{item.nickname}}</view>
				<view class="cont_r" >{{item.createtime | formatDate}}</view>	
			</view>
			 
			<view class="wu" v-if="list.length == 0">暂无数据~</view>
		</view>
		
	</view>
</template>

<script>
import getdata from '@/common/ajax.js';	
	export default {	
		data() {
			return {
				// list:[{sex:1,id:1,name:'隔壁山头女大王1',nickName:'张德涵1',location:'郑州',title:'热情活泼开朗大男孩一个',wx:'VX2354831'},
				// {sex:2,id:2,name:'隔壁山头女大王2',nickName:'张德涵2',location:'郑州',title:'热情活泼开朗大男孩一个',wx:'VX2354832'},
				// {sex:1,id:3,name:'隔壁山头女大王3',nickName:'张德涵3',location:'郑州',title:'热情活泼开朗大男孩一个',wx:'VX2354833'}],
				list:[],
				ajax:''
			}
		},
		onLoad() {
			
			this.tuandui()
			this.ajax = getdata.imgUrl
		},
		methods: {
			tuandui(){
				//获取用户信息
				uni.showLoading({
				    title: '加载中'
				});
				var _this = this
				var token = uni.getStorageSync('token')
				uni.request({
					url: getdata.websiteUrl + '/user/group',
					header:{'content-type': "application/x-www-form-urlencoded",token:token},
					dataType: 'json',
					method: 'POST',
					success: res => {
						uni.hideLoading();
						if(res.data.code == 1){
							_this.list = res.data.data
							console.log(res)
						}else if(res.data.code == 401){
							getdata.shou('请登录')
							uni.reLaunch({
							    url: '../login/login'
							});
						}else{
							getdata.shou(res.data.msg)
						}
						
					},
					fail: res => {
						uni.hideLoading();
						getdata.shou('服务器断开链接')
					}
				});
			}
		},
		filters:{
			//过滤器，时间戳转时间
				formatDate: function(value) {
					var date = new Date();
					//date.setTime(value);
					var month = date.getMonth() + 1;
					var hours = date.getHours();
					if (hours < 10)
						hours = "0" + hours;
					var minutes = date.getMinutes();
					if (minutes < 10)
						minutes = "0" + minutes;
					var time = date.getFullYear() + "-" + month + "-" + date.getDate() +
						" " + hours + ":" + minutes;
					return time;
				}
				
		},
	}
</script>

<style lang="scss">
@import '../../../static/iconfont/iconfont.css';	
.wu{
	text-align: center;
	font-size: 30rpx;
	color: #8D8D97;
}
.cont{
	width: 100%;
	box-sizing: border-box;
	padding: 0 50rpx;
	.cont_item{
		display: flex;
		margin-top: 40rpx;
		height: 80rpx;
		line-height: 80rpx;
		.cont_l{
		width: 80rpx;
		height: 80rpx;
		position: relative;
			image{
			width: 80rpx;	
			height: 80rpx;
			border-radius: 50%;
			}
			.sex{
				position: absolute;
				bottom:0;
				right:0;
				width: 28rpx;
				height: 28rpx;
				border-radius: 50%;
				background-color: #F2154E;
				.sex1{
					font-size: 22rpx;
					color: #fff;
					position: absolute;
					bottom:-28rpx;
					right:3rpx;
				}
			}
			.sex2{
				position: absolute;
				bottom:0;
				right:0;
				width: 28rpx;
				height: 28rpx;
				border-radius: 50%;
				background-color: #156DF2;
				.sex1{
					font-size: 22rpx;
					color: #fff;
					position: absolute;
					bottom:-28rpx;
					right:3rpx;
				}
			}
		}
		.cont_c{
			margin-left: 20rpx;
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #000000;
		}
		.cont_r{
			font-size: 24rpx;
			font-family: PingFang SC;
			color: #666666;
			margin-left: auto;
		}
	}
	
}	

</style>
